using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Pool;

public class PopupTextPool : MonoBehaviour
{
    public GameObject PopupText;

    private  ObjectPool<GameObject> popupTextPool;
    public static PopupTextPool instance;

    private void Awake()
    {
        if (instance == null)
        {

            instance = this;
        }
        else
        {
            Destroy(this.gameObject);

        }
        popupTextPool = new ObjectPool<GameObject>(createFunc,actionOnGet,actionOnRelease,actionOnDestroy,true,10,100);
    }

    public void actionOnDestroy(GameObject obj)
    {
        Destroy(obj);
    }

    public void actionOnRelease(GameObject obj)
    {
        obj.gameObject.SetActive(false);
    }

    public void actionOnGet(GameObject obj)
    {
        obj.gameObject.SetActive(true);
    }

    public GameObject createFunc()
    {
        var obj = Instantiate(PopupText,transform);
        return obj;
    }
}
